#include <iostream>
#include "redis_client.h"

using namespace std;

bool redis_client::init(std::string host, int port, std::string password) {
  context_ = redisConnect(host.c_str(), port);
  if (context_ == nullptr) {
    cout << "redisConnect error, context_ is nullptr" << endl;
    return false;
  } else if (context_->err) {
    cout << "redisConnect error, " << context_->errstr << endl;
    return false;
  }
  cout << "redisConnect succ" << endl;
}

void redis_client::close() {
  if (context_) {
    redisFree(context_);
  }
}